/**
 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

// Example of reading/writing an external serial flash using the PL022 SPI interface

#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/binary_info.h"
#include "hardware/spi.h"

#include "wizchip_conf.h"
#include "w5100s.h"
#include "w5100s_spi.h"

wiz_NetInfo net_info = {
    .mac = {0x00, 0x08, 0xdc, 0x1e, 0xed, 0x2e},
    .ip = {192, 168, 1, 10},
    .sn = {255, 255, 255, 0},
    .gw = {192, 168, 1, 1},
    .dns = {8,8,8,8},
};
wiz_NetInfo get_info;

int main()
{
    stdio_init_all();
    sleep_ms(2000);
    printf("W5100s network install example.\r\n");
    wizchip_initialize();
    wizchip_setnetinfo(&net_info);
    print_network_information(get_info);
    wizchip_getnetinfo(&get_info);
    sleep_ms(2000);
    while (true)
    {
        if (!wizphy_getphylink())
            printf("Please check the network cable connection.\r\n");
        else
            printf("Try ping the ip:%d.%d.%d.%d\r\n", get_info.ip[0], get_info.ip[1], get_info.ip[2], get_info.ip[3]);
        sleep_ms(2000);
    }
}
